class Collection {
  String? aid;
  String? mid;
  String? cover;
  String? uid;
  String? username;
  String? avatar;
  String? content;
  String? name;
  int? count;
  String? imgCount;
  String? collectionCount;
  String? type;
  int? createDate;

  Collection({
    required this.aid,
    required this.mid,
    required this.cover,
    required this.uid,
    required this.username,
    required this.avatar,
    required this.content,
    required this.name,
    required this.count,
    required this.imgCount,
    required this.collectionCount,
    required this.type,
    required this.createDate,
  });

  // 从JSON映射到对象
  factory Collection.fromJson(Map<String, dynamic> json) {
    return Collection(
      aid: json['aid'],
      mid: json['mid'],
      cover: json['cover'],
      uid: json['uid'],
      username: json['username'],
      avatar: json['avatar'],
      content: json['content'],
      name: json['name'],
      count: json['count'],
      imgCount: json['imgCount'],
      collectionCount: json['collectionCount'],
      type: json['type'].toString(),
      createDate: json['createDate'],
    );
  }

  // 从对象映射到JSON
  Map<String, dynamic> toJson() {
    return {
      'aid': aid,
      'mid': mid,
      'cover': cover,
      'uid': uid,
      'username': username,
      'avatar': avatar,
      'content': content,
      'name': name,
      'count': count,
      'imgCount': imgCount,
      'collectionCount': collectionCount,
      'type': type,
      'createDate': createDate,
    };
  }
}
class CollectionList {
  List<Collection> collections;

  CollectionList({required this.collections});

  // 从JSON映射到对象
  factory CollectionList.fromJson(List<dynamic> json) {
    List<Collection> collections = [];
    collections = json.map((item) => Collection.fromJson(item)).toList();
    return CollectionList(collections: collections);
  }

  // 从对象映射到JSON
  List<dynamic> toJson() {
    return collections.map((collection) => collection.toJson()).toList();
  }
}
